local gouhun = fk.CreateSkill {
  name = "th_gouhun",
}

gouhun:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    local to = data.to
    return target == player and player:hasSkill(gouhun.name) and data.card and data.card.trueName == "slash" and
    to and not to.dead
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = gouhun.name,
      prompt = "#th_gouhun-invoke::" .. data.to.id
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = data.to
    data.extra_data = data.extra_data or {}
    data.extra_data.th_gouhunUsed = true
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if to:compareDistance(p, 1, "<=") and p:getMark("@@th_gouhun-phase") == 0 then
        room:setPlayerMark(p, "@@th_gouhun-phase", 1)
      end
    end
  end,
})
gouhun:addEffect(fk.CardUseFinished, {
  can_refresh = function(self, event, target, player, data)
    return data.extra_data and data.extra_data.th_gouhunUsed
  end,
  on_refresh = function(self, event, target, player, data)
    for _, p in ipairs(player.room.alive_players) do
      player.room:setPlayerMark(p, "@@th_gouhun-phase", 0)
    end
  end
})
gouhun:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    return player:getMark("@@th_gouhun-phase") ~= 0
  end,
  prohibit_response = function(self, player, card)
    return player:getMark("@@th_gouhun-phase") ~= 0
  end
})

Fk:loadTranslationTable{
  ["th_gouhun"] = "勾魂",
  [":th_gouhun"] = "当你使用【杀】指定目标后，你可以令其距离不大于1的其他角色不能使用或打出牌直到此【杀】结算结束。",

  ["#th_gouhun-invoke"] = "勾魂：你可以令 %dest 距离不大于1的其他角色不能使用或打出牌直到此【杀】结算结束",

  ["@@th_gouhun-phase"] = "勾魂",
}

return gouhun